package com.nbgs.demo.controller;

import com.nbgs.demo.common.Alipay;
import com.nbgs.demo.common.Info.OrderForm;
import com.nbgs.demo.common.Result;
import com.nbgs.demo.model.User;
import com.nbgs.demo.service.TestService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "测试相关接口", description = "提供测试相关的 Rest API")
public class TestController {

    @Autowired
    private TestService testService;

    @GetMapping("/test")
    public void findUsers(){
//        throw new RuntimeException("didi");
//        log.info("{}");
//        List<User> users = testService.findUsers();
//        System.out.println(users);
    }
    @GetMapping("/add")
    public void addUser(){
        User user =new User();
        user.setIDNum("500382");
        user.setUserAddress("红旗河沟");
        user.setUsername("hkx");
        user.setUserTel("10086");
        testService.addUser(user);
    }

    @PostMapping("/payTest")
    public Result payTest(OrderForm orderForm){
        log.info("得到数据，{}",orderForm);
        Result alipay = Alipay.getAlipay(orderForm);
        System.out.println("返回到前端的result为"+alipay);
        return alipay;
    }

}
